﻿using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YiSha.Entity.Business;
using YiSha.Entity.OrganizationManage;
using YiSha.Model.Param.Business;
using YiSha.Model.Param.OrganizationManage;
using YiSha.Service.OrganizationManage;
using YiSha.Util.Extension;
using YiSha.Util.Model;

namespace YiSha.Business.Business
{
    public class TreatmentBLL
    {
        TreatmentService treatmentService = new TreatmentService();
        #region 获取数据
        public async Task<TData<List<TreatmentEntity>>> GetList(TreatmentParam param)
        {
            TData<List<TreatmentEntity>> obj = new TData<List<TreatmentEntity>>();
            obj.Data = await treatmentService.GetList(param);
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<TreatmentEntity>>> GetPageList(TreatmentParam param, Pagination pagination)
        {
            TData<List<TreatmentEntity>> obj = new TData<List<TreatmentEntity>>();
            obj.Data = await treatmentService.GetPageList(param, pagination);
            obj.Total = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<TreatmentEntity>> GetEntity(long id)
        {
            TData<TreatmentEntity> obj = new TData<TreatmentEntity>();
            obj.Data = await treatmentService.GetEntity(id);
            obj.Tag = 1;
            return obj;
        }


        #endregion

        #region 提交数据
        public async Task<TData<string>> SaveForm(TreatmentEntity entity)
        {
            TData<string> obj = new TData<string>();
            if (treatmentService.ExistPersonName(entity))
            {
                obj.Message = "存在标题相同的治疗方案！";
                return obj;
            }
            await treatmentService.SaveForm(entity);
            obj.Data = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await treatmentService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }
        #endregion
    }
}
